package com.bl.weilan.dao.model.converter;

import javax.persistence.AttributeConverter;
import java.util.Date;

public class DatetimeConverter implements AttributeConverter<Long, Date> {

    @Override
    public Date convertToDatabaseColumn(final Long attribute) {
        if (attribute == null) {
            return null;
        }
        return new Date(attribute);
    }

    @Override
    public Long convertToEntityAttribute(final Date dbData) {
        if (dbData == null) {
            return null;
        }
        return dbData.getTime();
    }

}
